% This code produces Table 4: Response to Monetary Policy Shock
% and Table 6: Response to Monetary Policy Shock (phi_pi = 2.5)

%clear all
clearvars -except wd
cd(fullfile(wd, 'Table3')); 
Table3 = zeros(9,5);

% Table 3: 341 sectors, cases 1-5
for ii=1:5
    output_mu_output_341 = dlmread(['Gensys_mu_output_main_case_' num2str(ii) 'params1_341.csv'],'\t',1,0);
        
        % output
        % impact
        Table3(1,ii) = output_mu_output_341(1,2);
        % cumulative
        Table3(2,ii) = output_mu_output_341(1,5);
        % persistence
        Table3(3,ii) = output_mu_output_341(1,37);

        % inflation
        % impact
        Table3(4,ii) = output_mu_output_341(1,3);
        % cumulative
        Table3(5,ii) = output_mu_output_341(1,6);
        % persistence
        Table3(6,ii) = output_mu_output_341(1,38);
        
        % real marginal costs
        % impact
        Table3(7,ii) = output_mu_output_341(1,4);
        % cumulative
        Table3(8,ii) = sum((output_mu_output_341(1,7:36))./341);
        % persistence
        Table3(9,ii) = output_mu_output_341(1,39);
end


n_cases = 5;

for jj=1:n_cases
    header1(:,jj) = [jj];
end

t3 = [header1; Table3];

cd(fullfile(wd, 'Table3')); 
%cd '/Users/raphaelschoenle/Dropbox/Networks/code/JME_post/Table3'
% save summary output
    filename = ['Table_3.csv'];
    dlmwrite(filename, t3, 'precision', '%.2f', 'delimiter', '\t');
    
%% Save ouput as Latex
row_labels = {'Impact        '; 'Cumulative IRF'; 'Persistence   '};

% save summary output as tex file
matrixTexTable(4, Table3, row_labels,'341_mu'); 


